home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume5 / vis.patch1 < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  11.9 KB

  1. Path: xanth!nic.MR.NET!hal!ncoast!allbery
  2. From: george@rebel.UUCP (George M. Sipe)
  3. Newsgroups: comp.sources.misc
  4. Subject: v05i005: (official) update #1 to vis
  5. Message-ID: <49579@rebel.UUCP>
  6. Date: 28 Oct 88 02:21:55 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: george@rebel.UUCP (George M. Sipe)
  9. Organization: Tolerant Systems, Atlanta GA
  10. Lines: 452
  11. Approved: allbery@ncoast.UUCP
  12.  
  13. Posting-number: Volume 5, Issue 5
  14. Submitted-by: "George M. Sipe" <george@rebel.UUCP>
  15. Archive-name: vis.Patch1
  16.  
  17. This update adds two useful new features to vis, the program recently
  18. posted which makes any command "screen oriented":
  19.  
  20.     1.  Steve Alter (alter@ttidca.tti.com) added the capability
  21.         to fully suppress the status line via a new -h option.
  22.         This permits the full screen to be used to display the
  23.         output of the command.
  24.  
  25.     2.  Anton Chernoff (abc@lpi.uucp) added the capability to
  26.         highlight characters changed since the last pass by the
  27.         use of standout mode, specified with a new -s option.
  28.  
  29. George M. Sipe,        Phone: (404) 662-1533
  30. Tolerant Systems, 6961 Peachtree Industrial, Norcross, GA  30071
  31. UUCP: ...!{decvax,hplabs,linus,rutgers,seismo}!gatech!rebel!george
  32.  
  33.  
  34. #! /bin/sh
  35. # This is a shell archive, meaning:
  36. # 1. Remove everything above the #! /bin/sh line.
  37. # 2. Save the resulting text in a file.
  38. # 3. Execute the file with /bin/sh (not csh) to create:
  39. #    README.diff
  40. #    vis.c.diff
  41. #    vis.man.diff
  42. # This archive created: Sun Oct 23 16:08:40 1988
  43. export PATH; PATH=/bin:/usr/bin:$PATH
  44. if test -f 'README.diff'
  45. then
  46.     echo shar: "will not over-write existing file 'README.diff'"
  47. else
  48. cat << \X > 'README.diff'
  49. *** README_orig    Sun Oct 23 15:10:24 1988
  50. --- README    Sun Oct 23 15:48:18 1988
  51. ***************
  52. *** 45,47
  53.       George M.  Sipe (rebel!george) to the point where Dan
  54.       would no longer recoginze it.  No copyright notices
  55.       were embodied in the original net distribution.
  56.  
  57. --- 45,51 -----
  58.       George M.  Sipe (rebel!george) to the point where Dan
  59.       would no longer recoginze it.  No copyright notices
  60.       were embodied in the original net distribution.
  61. +     Steve Alter (alter@ttidca.tti.com) added the -h option.
  62. +     Anton Chernoff (abc@lpi.uucp) added the -s option.
  63. X
  64. fi
  65. if test -f 'vis.c.diff'
  66. then
  67.     echo shar: "will not over-write existing file 'vis.c.diff'"
  68. else
  69. cat << \X > 'vis.c.diff'
  70. *** vis.c_orig    Sun Oct 23 15:10:30 1988
  71. --- vis.c    Sun Oct 23 15:47:01 1988
  72. ***************
  73. *** 27,32
  74.       Sipe (rebel!george) to the point where Dan would no longer
  75.       recoginze it.  No copyright notices were embodied in the
  76.       original net distribution.
  77.   */
  78.   
  79.   #include <stdio.h>
  80.  
  81. --- 27,36 -----
  82.       Sipe (rebel!george) to the point where Dan would no longer
  83.       recoginze it.  No copyright notices were embodied in the
  84.       original net distribution.
  85. +     Steve Alter (alter@ttidca.tti.com) added the -h option.
  86. +     Anton Chernoff (abc@lpi.uucp) added the -s option.
  87.   */
  88.   
  89.   #include <stdio.h>
  90. ***************
  91. *** 120,125
  92.       int sw;
  93.       int badsw = 0;
  94.       int baseline = BASELINE;
  95.       long nextcycle;
  96.       long curtime;
  97.       long delta;
  98.  
  99. --- 124,134 -----
  100.       int sw;
  101.       int badsw = 0;
  102.       int baseline = BASELINE;
  103. +     int doheader = 1;
  104. +     int flagchanges = 0;
  105. +     int flagch = 0;
  106. +     int y, x;
  107. +     int somode;
  108.       long nextcycle;
  109.       long curtime;
  110.       long delta;
  111. ***************
  112. *** 134,140
  113.       (void) signal(SIGINT, terminate);    /* exit when requested */
  114.       (void) signal(SIGPIPE, SIG_IGN);    /* when output > screen size */
  115.   
  116. !     while ((sw = getopt (argc, argv, "d:f")) != EOF)
  117.           switch (sw) {
  118.               case 'f':
  119.                   force = !force;
  120.  
  121. --- 143,149 -----
  122.       (void) signal(SIGINT, terminate);    /* exit when requested */
  123.       (void) signal(SIGPIPE, SIG_IGN);    /* when output > screen size */
  124.   
  125. !     while ((sw = getopt (argc, argv, "d:fhs")) != EOF)
  126.           switch (sw) {
  127.               case 'd':
  128.                   wait_delay = atoi(optarg);
  129. ***************
  130. *** 136,144
  131.   
  132.       while ((sw = getopt (argc, argv, "d:f")) != EOF)
  133.           switch (sw) {
  134. -             case 'f':
  135. -                 force = !force;
  136. -                 break;
  137.               case 'd':
  138.                   wait_delay = atoi(optarg);
  139.                   if (wait_delay < 1) wait_delay = 1;
  140.  
  141. --- 145,150 -----
  142.   
  143.       while ((sw = getopt (argc, argv, "d:fhs")) != EOF)
  144.           switch (sw) {
  145.               case 'd':
  146.                   wait_delay = atoi(optarg);
  147.                   if (wait_delay < 1) wait_delay = 1;
  148. ***************
  149. *** 143,148
  150.                   wait_delay = atoi(optarg);
  151.                   if (wait_delay < 1) wait_delay = 1;
  152.                   break;
  153.               case '?':
  154.               default:
  155.                   badsw = 1;
  156.  
  157. --- 149,164 -----
  158.                   wait_delay = atoi(optarg);
  159.                   if (wait_delay < 1) wait_delay = 1;
  160.                   break;
  161. +             case 'f':
  162. +                 force = !force;
  163. +                 break;
  164. +             case 'h':
  165. +                 doheader = 0;
  166. +                 baseline = 0;
  167. +                 break;
  168. +             case 's':
  169. +                 flagchanges = !flagchanges;
  170. +                 break;
  171.               case '?':
  172.               default:
  173.                   badsw = 1;
  174. ***************
  175. *** 152,158
  176.       argc -= optind;
  177.       if (badsw || argc < 1) {
  178.           (void) fprintf(stderr,
  179. !             "Usage: %s [-d delay] [-f] command [args]\n", cmd);
  180.           exit (-1);
  181.       }
  182.       initscr();
  183.  
  184. --- 168,175 -----
  185.       argc -= optind;
  186.       if (badsw || argc < 1) {
  187.           (void) fprintf(stderr,
  188. !             "Usage: %s [-d delay] [-f] [-h] [-s] command [args]\n",
  189. !             cmd);
  190.           exit (-1);
  191.       }
  192.       initscr();
  193. ***************
  194. *** 163,176
  195.           shcmd[2] = cmd;
  196.           shcmd[3] = (char *) 0;
  197.       }
  198. !     if (wait_delay != DELAY) {
  199. !         if (strlen(cmd) > COLS-39)
  200. !             (void) sprintf(cmd, "%.*s...", COLS-42, cmd);
  201. !         mvprintw(0, max((COLS-11)/2, strlen(cmd)+15), "Delay:  %d",
  202. !             wait_delay);
  203. !     } else if (strlen(cmd) > COLS-21)
  204. !         (void) sprintf(cmd, "%.*s...", COLS-24, cmd);
  205. !     mvprintw(0, 0, "Command:  %s", cmd);
  206.       noecho();            /* don't let typing ruin our painting */
  207.       nextcycle = time(0) + wait_delay;
  208.       while (1) {
  209.  
  210. --- 180,195 -----
  211.           shcmd[2] = cmd;
  212.           shcmd[3] = (char *) 0;
  213.       }
  214. !     if (doheader) {
  215. !         if (wait_delay != DELAY) {
  216. !             if (strlen(cmd) > COLS-39)
  217. !                 (void) sprintf(cmd, "%.*s...", COLS-42, cmd);
  218. !             mvprintw(0, max((COLS-11)/2, strlen(cmd)+15),
  219. !                 "Delay:  %d", wait_delay);
  220. !         } else if (strlen(cmd) > COLS-21)
  221. !             (void) sprintf(cmd, "%.*s...", COLS-24, cmd);
  222. !         mvprintw(0, 0, "Command:  %s", cmd);
  223. !     }
  224.       noecho();            /* don't let typing ruin our painting */
  225.       nextcycle = time(0) + wait_delay;
  226.       while (1) {
  227. ***************
  228. *** 174,180
  229.       noecho();            /* don't let typing ruin our painting */
  230.       nextcycle = time(0) + wait_delay;
  231.       while (1) {
  232. !         mvprintw(0, COLS - 10, "Exec:  %d", ++iteration);
  233.           if (iteration == 1) refresh();
  234.           (void) pipe(fildes);
  235.           /* fork and exec redirecting stdout thru pipe to curses */
  236.  
  237. --- 193,200 -----
  238.       noecho();            /* don't let typing ruin our painting */
  239.       nextcycle = time(0) + wait_delay;
  240.       while (1) {
  241. !         if (doheader)
  242. !             mvprintw(0, COLS - 10, "Exec:  %d", ++iteration);
  243.           if (iteration == 1) refresh();
  244.           (void) pipe(fildes);
  245.           /* fork and exec redirecting stdout thru pipe to curses */
  246. ***************
  247. *** 191,196
  248.           if (!(fp = fdopen(pinput, "r"))) terminate(-3);
  249.           (void) close(poutput);
  250.           curline = baseline;
  251.           move(curline, 0);
  252.           /* read the command's output */
  253.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  254.  
  255. --- 211,217 -----
  256.           if (!(fp = fdopen(pinput, "r"))) terminate(-3);
  257.           (void) close(poutput);
  258.           curline = baseline;
  259. +         somode = 0;
  260.           move(curline, 0);
  261.           getyx(stdscr, y, x);
  262.           /* read the command's output */
  263. ***************
  264. *** 192,197
  265.           (void) close(poutput);
  266.           curline = baseline;
  267.           move(curline, 0);
  268.           /* read the command's output */
  269.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  270.                   if (c == '\n') {
  271.  
  272. --- 213,219 -----
  273.           curline = baseline;
  274.           somode = 0;
  275.           move(curline, 0);
  276. +         getyx(stdscr, y, x);
  277.           /* read the command's output */
  278.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  279.           {
  280. ***************
  281. *** 194,204
  282.           move(curline, 0);
  283.           /* read the command's output */
  284.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  285. !                 if (c == '\n') {
  286. !                     clrtoeol();
  287. !                     move(++curline, 0);
  288. !                 }
  289. !                 else addch(c);
  290.           if (ferror(fp)) terminate(-4);
  291.           if (baseline > 1 && curline == LINES && c != EOF)
  292.               --baseline;
  293.  
  294. --- 216,250 -----
  295.           getyx(stdscr, y, x);
  296.           /* read the command's output */
  297.           while ((c = getc(fp)) != EOF && !ferror(fp) && curline < LINES)
  298. !         {
  299. !             if (c == '\n') {
  300. !                 if (x < COLS-1) clrtoeol();
  301. !                 move(++curline, 0);
  302. !                 getyx(stdscr, y, x);
  303. !             }
  304. !             else {
  305. !                 if (x >= COLS-1)
  306. !                     continue;
  307. !                 getyx(stdscr, y, x);
  308. !                 if (flagch)
  309. !                     if ((c & 0177) == (inch() & 0177)) {
  310. !                         if (somode) {
  311. !                             standend();
  312. !                             somode = 0;
  313. !                         }
  314. !                     }
  315. !                     else {
  316. !                         if (!somode) {
  317. !                             standout();
  318. !                             somode = 1;
  319. !                         }
  320. !                     }
  321. !                 addch(c);
  322. !             }
  323. !         }
  324. !         if (somode) standend();
  325. !         flagch = flagchanges;
  326.           if (ferror(fp)) terminate(-4);
  327.           if (baseline > 1 && curline == LINES && c != EOF)
  328.               --baseline;
  329. ***************
  330. *** 210,216
  331.           (void) wait(&status);    /* wait for child to terminate */
  332.           /* if child didn't terminate properly, w_status will != 0 */
  333.           if (status.w_status) {
  334. !             mvprintw(0, COLS - 12, "!");
  335.               if (!force) terminate(status.w_status);
  336.           }
  337.           curtime = time(0);
  338.  
  339. --- 256,263 -----
  340.           (void) wait(&status);    /* wait for child to terminate */
  341.           /* if child didn't terminate properly, w_status will != 0 */
  342.           if (status.w_status) {
  343. !             if (doheader)
  344. !                 mvprintw(0, COLS - 12, "!");
  345.               if (!force) terminate(status.w_status);
  346.           }
  347.           curtime = time(0);
  348. X
  349. fi
  350. if test -f 'vis.man.diff'
  351. then
  352.     echo shar: "will not over-write existing file 'vis.man.diff'"
  353. else
  354. cat << \X > 'vis.man.diff'
  355. *** vis.man_orig    Sun Oct 23 15:10:27 1988
  356. --- vis.man    Sun Oct 23 15:47:13 1988
  357. ***************
  358. *** 1,4
  359. ! .TH VIS l "21 July 1988"
  360.   .SH NAME
  361.   vis \- repeatedly run command, refreshing screen
  362.   .SH SYNTAX
  363.  
  364. --- 1,4 -----
  365. ! .TH VIS l "24 October 1988"
  366.   .SH NAME
  367.   vis \- repeatedly run command, refreshing screen
  368.   .SH SYNTAX
  369. ***************
  370. *** 2,8
  371.   .SH NAME
  372.   vis \- repeatedly run command, refreshing screen
  373.   .SH SYNTAX
  374. ! .B vis "[-d delay] [-f] command [args]"
  375.   .SH DESCRIPTION
  376.   .I Vis
  377.   repeatedly executes a specified
  378.  
  379. --- 2,8 -----
  380.   .SH NAME
  381.   vis \- repeatedly run command, refreshing screen
  382.   .SH SYNTAX
  383. ! .B vis "[-d delay] [-f] [-h] [-s] command [args]"
  384.   .SH DESCRIPTION
  385.   .I Vis
  386.   repeatedly executes a specified
  387. ***************
  388. *** 67,72
  389.   status line by a ``!'' flag whenever a non-zero status has been returned
  390.   by
  391.   .B command .
  392.   .SH EXAMPLES
  393.   vis ps
  394.   .IP "" 5
  395.  
  396. --- 67,85 -----
  397.   status line by a ``!'' flag whenever a non-zero status has been returned
  398.   by
  399.   .B command .
  400. + .TP
  401. + .B -h
  402. + causes the entire status line and the following blank line to be
  403. + suppressed, which leaves the full screen available for the output of
  404. + .B command .
  405. + .TP
  406. + .B -s
  407. + causes
  408. + .I vis
  409. + to use standout mode for any bytes that have changed between the
  410. + previous execution of
  411. + .B command
  412. + and the current one.
  413.   .SH EXAMPLES
  414.   vis ps
  415.   .IP "" 5
  416. ***************
  417. *** 77,82
  418.   .IP "" 5
  419.   Display the system users and disk usage statistics every 60 seconds.
  420.   Separate the two with a blank line.
  421.   .SH "SEE ALSO"
  422.   User Commands (1):  sh, csh
  423.   .SH DIAGNOSTICS
  424.  
  425. --- 90,100 -----
  426.   .IP "" 5
  427.   Display the system users and disk usage statistics every 60 seconds.
  428.   Separate the two with a blank line.
  429. + .PP
  430. + vis -s ls -l
  431. + .IP "" 5
  432. + Continually display a long directory listing, highlighting via standout
  433. + mode the parts that change each time.
  434.   .SH "SEE ALSO"
  435.   User Commands (1):  sh, csh
  436.   .SH DIAGNOSTICS
  437. ***************
  438. *** 94,96
  439.   It has been substantially enhanced and generalized by George M. Sipe
  440.   (currently - 7/88, at rebel!george) to the point where Dan would no
  441.   longer recognize it.
  442.  
  443. --- 112,118 -----
  444.   It has been substantially enhanced and generalized by George M. Sipe
  445.   (currently - 7/88, at rebel!george) to the point where Dan would no
  446.   longer recognize it.
  447. + .PP
  448. + Steve Alter (alter@ttidca.tti.com) added the -h option.
  449. + .PP
  450. + Anton Chernoff (abc@lpi.uucp) added the -s option.
  451. X
  452. fi
  453. exit 0
  454. #    End of shell archive
  455.  
  456. -- 
  457. George M. Sipe,        Phone: (404) 662-1533
  458. Tolerant Systems, 6961 Peachtree Industrial, Norcross, GA  30071
  459. UUCP: ...!{decvax,hplabs,linus,rutgers,seismo}!gatech!rebel!george
  460.